﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeaBattle.Domain.Entities
{
    public class Account
    {
        public decimal Balance { get; private set; }
        public Player Owner { get; private set; }

        public Account(decimal balance, Player owner)
        {
            Balance = balance;
            Owner = owner;
        }

        /// <summary>
        /// Modifies Balance on value "amount"
        /// </summary>
        /// <param name="amount">can be negative</param>
        /// <returns></returns>
        public decimal AddAmount(decimal amount)
        {
            if (Balance + amount < 0)
            {
                throw new ArithmeticException("Balance cannot be negative");
            }
            Balance += amount;
            return Balance;
        }
    }
}